<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script type="module">

        import { A, privateBySymbol, privateByWeakMap, privateByHash, privateByClosure } from './utils.js'

        console.log(new A().__name)

        const symbolObj = new privateBySymbol()
        console.log(symbolObj.f)
        // 缺点，通过Object.getOwnPropertySymbols()可以获取到私有属性
        const keys = Object.getOwnPropertySymbols(symbolObj)
        console.log(keys,symbolObj[keys[0]]) // 访问到了

        // 这个可以，访问不到privateMap
        const weakMapObj = new privateByWeakMap()
        console.log(weakMapObj.name)

        // 推荐做法，但是兼容性问题
        const hashObj = new privateByHash()
        console.log(hashObj.privateName)

        // 闭包
        const closureObj =  privateByClosure()
        console.log(closureObj.privateName)

        

    </script>

</body>

</html>